/*
 * @Date: 2022-04-12 09:06:05
 * @LastEditors: 春贰
 * @gitee: https://gitee.com/chun22222222
 * @github: https://github.com/chun222
 * @Desc:
 * @LastEditTime: 2022-06-15 15:00:31
 * @FilePath: \server\system\controller\sys\tools\tools.go
 */
package tools

import (
	"go2admin_pure/system/common/sequence"
	"go2admin_pure/system/core/request"
	"go2admin_pure/system/core/response"
	"go2admin_pure/system/model/RequestModel"
	"go2admin_pure/system/service/SysConfigService"
	"github.com/gin-gonic/gin"
)

/**
 *
 * @api {post} /tools/sequence 获取序列号
 * @apiName 获取序列号
 * @apiGroup 用户
 * @apiVersion  1.0.0
 *
 * @apiBody  {String}  page
 * @apiBody  {String}  pageSize
 * @apiSampleRequest /user/list
 * @apiHeader {String} Authorization 唯一token
 *
 * @apiParamExample  {json} Request-Example:
 * {
 *    key : "value",
 * }
 *
 *
 * @apiSuccessExample {json} Success-Response:
 *
 {
  "code": 0,
	 "data": {
	 },
	 "msg": "sucess"
 }
 *
 *
*/
func Sequence(c *gin.Context) {
	var r RequestModel.Sequence
	err, msg := request.Binding(&r, c)
	if err != nil {
		response.FailWithMessage(msg, c)
		return
	}

	err, seq := sequence.GetString(r.Pre, r.Length)
	if err != nil {
		response.FailWithMessage(msg, c)
		return
	}
	response.OkWithData(seq, c)

}

//获取配置
func Config(c *gin.Context) {
	var SysConfigSer SysConfigService.SysConfigService
	err, configs := SysConfigSer.AllConfig()
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.OkWithData(configs, c)
}
